/*
 *  atold.c (part of p8.c)
 *  
 *
 *  Created by Shang-Ju Chen on 3/5/11.
 *  check on 2/7/11
 *
 */

long double
atold( char *a )
{	
	long double y;
	int n,p,s;
	
	y = (long double) 0;
	n = p = s = 0;
	
	while ((*a == '') || (*a == '\t'))
	{
		a++;
	}
	
	if (*a == '-')
	{
		a++;
		s++;
	}
	
	while(isdigit(*a))
	{
		y = (long double) 10 * y + (long double)((*a++) - '0');
	}
	
	if(*a=='.')
	{
		a++;
		while (isdigit(*a))
		{
			y = (long double) 10 * y + (long double)((*a++) - '0');		
		}
	}
	
	if ((*a == 'e') || (*a == 'E'))
	{
		n = atoi(++a);
	}
	
	y = y * tento(n - p);
	return(s ? -y: y);
}
